
import { useRoutes } from 'react-router-dom'
import Login from '@/pages/Login';
import Notfound from '@/pages/NotFound';
import { AuthRoute } from '@/components/AuthRoute';
import Home from '@/pages/Home';
import Article from '@/pages/Article';
import Publish from '@/pages/Publish';
import Team1 from '@/pages/Team/team1';
import Team2 from '@/pages/Team/team2';
import LayoutCon from '@/pages/Layout';

// 1. 准备一个路由数组 数组中定义所有的路由对应关系
const routesList = [
    {
      path: '/layout',
      element: <AuthRoute><LayoutCon /></AuthRoute>,
      children: [
        {
          path: 'home',
          element: <Home />,
          index: true, // index设置为true 变成默认的二级路由
        },
        {
          path: 'article',
          element: <Article />,
          index: true, // index设置为true 变成默认的二级路由
        },
        {
          path: 'publish',
          element: <Publish />,
          index: true, // index设置为true 变成默认的二级路由
        },
        {
          path: 'team',
          element: <Team1 />,
          index: true,
        },
        {
          path: 'team/team1',
          element: <Team1 />,
          index: true,
        },
        {
          path: 'team/team2',
          element: <Team2 />,
          index: true, 
        },
      ],
    },
    {
      path: '/',
      element: <Login /> ,
    },
    {
        path: '/login',
        element: <Login />,
    },
    // 增加n个路由对应关系
    {
      path: '*',
      element: <Notfound />,
    },
  ]
  
  // 2. 使用useRoutes方法传入routesList生成Routes组件
  function WrapperRoutes() {
    let element = useRoutes(routesList)
    return element
  }

  export default WrapperRoutes;
  